﻿using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;

namespace WeiSha.Core
{
	// Token: 0x0200001C RID: 28
	internal class Activationcode
	{
		// Token: 0x0600009C RID: 156 RVA: 0x00002EA2 File Offset: 0x000010A2
		private Activationcode()
		{
		}

		// Token: 0x17000026 RID: 38
		// (get) Token: 0x0600009D RID: 157 RVA: 0x0000578F File Offset: 0x0000398F
		internal static string CodeForCPU
		{
			get
			{
				return Activationcode.RegistCode(1, Server.CPU_ID);
			}
		}

		// Token: 0x17000027 RID: 39
		// (get) Token: 0x0600009E RID: 158 RVA: 0x0000579C File Offset: 0x0000399C
		internal static string CodeForHardDisk
		{
			get
			{
				return Activationcode.RegistCode(2, Server.HardDiskID);
			}
		}

		// Token: 0x17000028 RID: 40
		// (get) Token: 0x0600009F RID: 159 RVA: 0x000057A9 File Offset: 0x000039A9
		internal static string CodeForIP
		{
			get
			{
				return Activationcode.RegistCode(3, Server.IP + ":" + Server.Port);
			}
		}

		// Token: 0x17000029 RID: 41
		// (get) Token: 0x060000A0 RID: 160 RVA: 0x000057C5 File Offset: 0x000039C5
		internal static string CodeForDomain
		{
			get
			{
				return Activationcode.RegistCode(4, Server.Domain + ":" + Server.Port);
			}
		}

		// Token: 0x1700002A RID: 42
		// (get) Token: 0x060000A1 RID: 161 RVA: 0x000057E1 File Offset: 0x000039E1
		internal static string CodeForRoot
		{
			get
			{
				return Activationcode.RegistCode(5, Server.MainName + ":" + Server.Port);
			}
		}

		// Token: 0x060000A2 RID: 162 RVA: 0x00005800 File Offset: 0x00003A00
		internal static string RegistCode(int type, string value)
		{
			value = string.Concat(new string[]
			{
				value,
				"$",
				Platform.Name,
				"$",
				Platform.Version
			});
			byte[] array = new byte[] { 18, 52, 86, 120, 144, 171, 205, 239 };
			string text4;
			try
			{
				string text = Request.Random(8, 6);
				byte[] bytes = Encoding.UTF8.GetBytes(text.ToLower());
				DESCryptoServiceProvider descryptoServiceProvider = new DESCryptoServiceProvider();
				byte[] bytes2 = Encoding.UTF8.GetBytes(value);
				MemoryStream memoryStream = new MemoryStream();
				CryptoStream cryptoStream = new CryptoStream(memoryStream, descryptoServiceProvider.CreateEncryptor(bytes, array), CryptoStreamMode.Write);
				cryptoStream.Write(bytes2, 0, bytes2.Length);
				cryptoStream.FlushFinalBlock();
				string text2 = Convert.ToBase64String(memoryStream.ToArray());
				string text3 = "";
				for (int i = 0; i < text2.Length; i++)
				{
					bool flag = i < text.Length;
					if (flag)
					{
						text3 = text3 + text2.Substring(i, 1) + text.Substring(i, 1);
					}
					else
					{
						text3 += text2.Substring(i, 1);
					}
				}
				text4 = type.ToString() + text3;
			}
			catch (Exception ex)
			{
				text4 = ex.Message;
			}
			return text4;
		}
	}
}
